window.px = "";
        window.py = "";
        window.divLength = 0;
        var container_id = 'div_div'
        function dian(e) {//鼠标单击不放
            px = e.pageX;//获取x坐标
            py = e.pageY;//获取y坐标
        }
        function yi(e) {       //鼠标移动
            if (px == "" || py == "") {
                return;
            }
            if (divLength == 0) {
                divLength = $("#"+container_id).children(".diyi").length;
            }
            $("#"+container_id).unbind("mouseover");
            var pxx = e.pageX;
            var pyy = e.pageY;
            var h = pyy - py;
            var w = pxx - px;
            //画出矩形选中框
            if (h < 0 && w >= 0) {
                $("#container").css({ "height": (-h) + "px", "width": w + "px", "position": "absolute", "left": px + "px", "top": pyy + "px", "opacity": "0.2", "border": "1px dashed #000" });
            }
            else if (h >= 0 && w < 0) {
                $("#container").css({ "height": h + "px", "width": (-w) + "px", "position": "absolute", "left": pxx + "px", "top": py + "px", "opacity": "0.2", "border": "1px dashed #000" });
            }
            else if (h < 0 && w < 0) {
                $("#container").css({ "height": (-h) + "px", "width": (-w) + "px", "position": "absolute", "left": pxx + "px", "top": pyy + "px", "opacity": "0.2", "border": "1px dashed #000" });
            }
            else {
                $("#container").css({ "height": h + "px", "width": w + "px", "position": "absolute", "left": px + "px", "top": py + "px", "opacity": "0.2", "border": "1px dashed #000" });
            }
            if (w < 0) {
                w = 0 - w;
            }
            if (h < 0) {
                h = 0 - h;
            }
            //获取选中框的4个定点坐标
            var x1 = $("#container").offset().left;
            var y1 = $("#container").offset().top;
            var x2 = x1 + w;
            var y2 = y1;
            var x3 = x1 + w;
            var y3 = y1 + h;
            var x4 = x1;
            var y4 = y1 + h;
            var bianseId = "";
            //循环判断选中框选中那些内容
            for (var i = 1; i <= divLength; i++)//i的 最大值稍后修改
            {
                var x11 = $("#div" + i).offset().left;
                var y11 = $("#div" + i).offset().top;
                var x22 = x11 + 150;
                var y22 = y11;
                var x33 = x11 + 150;
                var y33 = y11 + 100;
                var x44 = x11;
                var y44 = y11 + 100;
                var panduan = false;
                //判断方法 判断文本框的4个坐标点是否在选中框中，判断选中框的4个坐标点是否在文本框，判断选中框从中间选中是否覆盖
                if ((x11 > x1 && y11 > y1) && (x11 < x2 && y11 > y2) && (x11 < x3 && y11 < y3) && (x11 > x4 && y11 < y4)) {
                    panduan = true;
                }
                else if ((x22 > x1 && y22 > y1) && (x22 < x2 && y22 > y2) && (x22 < x3 && y22 < y3) && (x22 > x4 && y22 < y4)) {
                    panduan = true;
                }
                else if ((x33 > x1 && y33 > y1) && (x33 < x2 && y33 > y2) && (x33 < x3 && y33 < y3) && (x33 > x4 && y33 < y4)) {
                    panduan = true;
                }
                else if ((x44 > x1 && y44 > y1) && (x44 < x2 && y44 > y2) && (x44 < x3 && y44 < y3) && (x44 > x4 && y44 < y4)) {
                    panduan = true;
                }
                    //反向
                else if ((x1 > x11 && y1 > y11) && (x1 < x22 && y1 > y22) && (x1 < x33 && y1 < y33) && (x1 > x44 && y1 < y44)) {
                    panduan = true;
                }
                else if ((x2 > x11 && y2 > y11) && (x2 < x22 && y2 > y22) && (x2 < x33 && y2 < y33) && (x2 > x44 && y2 < y44)) {
                    panduan = true;
                }
                else if ((x3 > x11 && y3 > y11) && (x3 < x22 && y3 > y22) && (x3 < x33 && y3 < y33) && (x3 > x44 && y3 < y44)) {
                    panduan = true;
                }
                else if ((x4 > x11 && y4 > y11) && (x4 < x22 && y4 > y22) && (x4 < x33 && y4 < y33) && (x4 > x44 && y4 < y44)) {
                    panduan = true;
                }
                    //中间横
                else if ((x1 > x11 && y1< y11) && (x2 < x22 && y2 < y22) && (x3 < x33 && y3 > y33) && (x4 > x44 && y4 > y44)) {
                    panduan = true;
                }
                    //中间竖
                else if ((x11 > x1 && y11 < y1) && (x22 < x2 && y22 < y2) && (x33 < x3 && y33 > y3) && (x44 > x4 && y44 > y4)) {
                    panduan = true;
                }
                if (panduan == true) {
                    bianseId = "div" + i + "," + bianseId;
                }
            }
            if (bianseId == "") {
                for (var j = 1; j <= divLength; j++) {
                    $("#div" + j).find(".disan").css({ "border": "2px solid #fff" });
                    $("#div" + j).find(".dier").css({ "background-position": "6px -36px", "display": "none" });
                    //$("#div" + j).css({ "background-color": "#fff" });
                }
            }
            var idObj = bianseId.split(",");
            if (idObj.length - 1 == divLength) {
                for (var j = 0; j < idObj.length - 1; j++) {
                    //$("#" + idObj[j]).css({ "background-color": "red" });
                    $("#" + idObj[j]).find(".disan").css({ "border": "2px solid #2e80dc" });
                    $("#" + idObj[j]).find(".dier").css({ "background-position": "-30px -36px", "display": "block" });
                }
            }
            else {
                for (var j = 1; j <= divLength; j++) {
                    var xuanzhong = false;
                    for (var i = 0; i < idObj.length - 1; i++) {
                        if ("div" + j == idObj[i]) {
                            xuanzhong = true;
                        }
                    }
                    if (xuanzhong == true) {
                        $("#div" + j).find(".disan").css({ "border": "2px solid #2e80dc" });
                        $("#div" + j).find(".dier").css({ "background-position": "-30px -36px", "display": "block" });
                        //$("#div" + j).css({ "background-color": "red" });
                    }
                    else {
                        $("#div" + j).find(".disan").css({ "border": "2px solid #fff" });
                        $("#div" + j).find(".dier").css({ "background-position": "6px -36px", "display": "none" });
                        //$("#div" + j).css({ "background-color": "#fff" });
                    }
                }
            }
        }
        function li() {//鼠标点击放开进行初始化
            px = "";
            py = "";
            $("#container").css({ "height": "0", "width": "0", "border": "0px" });
            $("#"+container_id).bind("mouseover", function (event) {
                xuan(event);
            });
        }
        function xuan(e)
        {
            if (divLength == 0)
            {
                divLength = $("#"+container_id).children(".diyi").length;
            }
            var divIdObj = $(e.target).attr("id");
            if (divIdObj == "div_div")
            {
                for(var i=1;i<=divLength;i++)
                {
                    var bgValue = $("#div" + i).find(".dier").css("background-position");
                    if (bgValue == "-30px -36px") {
                    }
                    else {
                        $("#div" + i).find(".dier").css({ "display": "none" });
                        $("#div" + i).find(".disan").css({ "border": "2px solid #fff" });
                    }
                }
            }
            var divId = divIdObj.split("_")[0];
            for (var i = 1; i <= divLength; i++)
            {
                if(divId==("div"+i))
                {
                    $("#" + divId).find(".disan").css({ "border": "2px solid #2e80dc" });
                    $("#" + divId).find(".dier").css({ "display": "block" });
                }
                else
                {

                    var bgValue = $("#div" + i).find(".dier").css("background-position");
                    if (bgValue == "-30px -36px") {
                    }
                    else {
                        $("#div" + i).find(".dier").css({ "display": "none" });
                        $("#div" + i).find(".disan").css({ "border": "2px solid #fff" });
                    }
                }
            }
        }

        function dianji(e)//点击
        {
            var divId = $(e.target).attr("id");
            var spanId = divId.split("_");
            if (spanId.length == 3 && spanId[2] == "img")
            {
                var bgValue = $("#" + divId).css("background-position");
                if (bgValue == "-30px -36px")
                {
                    $("#" + divId).css({ "background-position": "6px -36px", "display": "block" });
                    return;
                }
                $("#" + divId).css({ "background-position": "-30px -36px","display":"block" });
            }
            if (spanId.length == 2 && spanId[1] == "1")
            {
                alert(divId);
            }
        }
        $(document).ready(function () {
            $("#"+container_id).bind("mouseover", function (event) {
                xuan(event);
            })
        });
